import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import {TagState} from "../../types";
export interface UserState {
  id: string;
  token: string;
  avator: string;
  nickname: string;
  list: TagState[];
}
const initialState: UserState = {
  id: "",
  token: "",
  avator: "",
  nickname: "",
  list: [],
};
const userSlice = createSlice({
  name: "user",
  initialState,
  reducers: {
    loginSuccess(state, action: PayloadAction<UserState>) {
      state.id = action.payload.id;
      state.token = action.payload.token;
      state.avator = action.payload.avator;
      state.nickname = action.payload.nickname;
      state.list = action.payload.list;
    },
  },
});
export const { loginSuccess } = userSlice.actions;
export default userSlice;
